package com.matt.docpro.service;

import com.matt.docpro.mapper.AdminMapper;
import com.matt.docpro.mapper.CheckinMapper;
import com.matt.docpro.mapper.UserMapper;
import com.matt.docpro.model.Admin;
import com.matt.docpro.model.Checkin;
import com.matt.docpro.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AppointmentService
 * Created by on 2024/02/20.
 */
@Service
public class AdminService {

    @Autowired
    AdminMapper adminMapper;
    @Autowired
    UserMapper userMapper;

    public List<Admin> getAll() {
        return adminMapper.getAll();
    }

    public Admin getById(String id) {
        return adminMapper.getById(id);
    }

    public int getCount() {
        return adminMapper.getCount();
    }

    public void update(Admin admin) {
        adminMapper.update(admin);
    }

    public void insert(Admin admin) {
        adminMapper.insert(admin);
        User user = new User();
        user.setId(admin.getId());
        user.setPassword("123456");
        user.setAccount(admin.getId());
        user.setMail(admin.getMail());
        user.setBaned(false);
        user.setRole("0");
        userMapper.insert(user);
    }

}
